package com.qidian.mes.cal.controller;

import com.qidian.mes.cal.service.CalPlanService;
import com.qidian.mes.pojo.CalPlan;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
@RequestMapping("/plan")
public class CalPlanController {//排班计划
    @Autowired
    CalPlanService calPlanService;

    @GetMapping("/selectByType")
    //根据分类查询计划
    public MESResult selectByType(String calendarType){
        return calPlanService.selectByType(calendarType);
    }
    @PostMapping("/update")
    //修改计划
    public MESResult update(@RequestBody CalPlan calPlan) {
        return calPlanService.update(calPlan);
    }

    @GetMapping("/list")
    //分页查询
    public MESResult list(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = " 10") int limit, CalPlan calPlan) {
        return calPlanService.list(page,limit,calPlan);
    }

    @PostMapping("/save")
    //添加计划
    public MESResult save(@RequestBody CalPlan calPlan) {
        return calPlanService.save(calPlan);
    }

    @GetMapping("/selectByPlanId")
    //根据id查询排班计划详情
    public MESResult selectByPlanId(Long planId) {
        return calPlanService.selectByPlanId(planId);
    }

    @DeleteMapping("/delete")
    //删除计划
    public MESResult delete(Long[] planIds) {
        return calPlanService.delete(planIds);
    }
}
